package com.qyhl.webtv.module_microvideo.shortvideo.theme;


import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.entity.microvideo.ShortVideoThemeBean;
import com.qyhl.webtv.module_microvideo.common.VideoUrl;

import java.util.List;

public class ShortVideoThemeModel implements ShortVideoThemeContract.ShortVideoThemeModel {
    private ShortVideoThemePresenter mPresenter;

    ShortVideoThemeModel(ShortVideoThemePresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    @Override
    public void getList(String actId) {

        EasyHttp.get(VideoUrl.GET_SHORT_VIDEO_THEME_LIST)
                .params("actId", actId)
                .execute(new SimpleCallBack<List<ShortVideoThemeBean>>() {
                    @Override
                    public void onError(ApiException e) {
                        if (e.getCode() == 202) {
                            mPresenter.setError("暂无任何内容，请稍后再试！");
                        } else {
                            mPresenter.setError("请求失败，请重新获取！");
                        }
                    }

                    @Override
                    public void onSuccess(List<ShortVideoThemeBean> shortVideoThemeBeans) {
                        if (shortVideoThemeBeans != null && shortVideoThemeBeans.size() > 0) {
                            mPresenter.setList(shortVideoThemeBeans);
                        } else {
                            mPresenter.setError("暂无任何内容，请稍后再试！");
                        }
                    }
                });

    }
}
